use std::str::FromStr;

#[derive(Debug)]
enum MyField {
    name,
    age,
    name1(String),
}

enum MyEnum1 {
    Name = 1,
    Age = 2,
}

struct Builder {
    params : Vec<MyField>,
}

impl Builder {

    fn builder() ->Self {
        Builder { params : Vec::new()}
    }

    fn set_name(&mut self) {
        self.params.push(MyField::name);
    }

    fn set_age(&mut self) { 
        self.params.push(MyField::age);
    }

    fn get_result(&self) -> String {
        let mut s = String::new();
        s.push_str("select ");
        let _ = &self.params.iter().for_each(|_e|  {
            s.push_str(&format!("{:?}",_e));
            s.push(',');
        
        });
           
        s.push_str(" t_sys");
        return s;
    }
}

#[cfg(test)]
mod test {
    use crate::my_enum::MyEnum1;

    use super::*;




    #[test]
    fn test() {
        let mut fields: Vec<MyField> = Vec::new();
        fields.push(MyField::name);
        fields.push(MyField::age);
        
    }

    #[test]
    fn test2() {
       
        println!("{:?}", MyEnum1::Name as i32);
        
    }

    #[test]
    fn test3() {
        let mut builder = Builder::builder();
        builder.set_name();
        builder.set_age();
        let sql = builder.get_result();
        println!("{}", sql);
    }

}